import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:mall/constant/app_colors.dart';
import 'package:mall/utils/hud/hud_util.dart';

class AppCopyBtn extends StatelessWidget {
  const AppCopyBtn({
    super.key,
    required this.text,
  });

  final String text;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      child: Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(10),
          color: Color(0xfff2f2f2),
        ),
        alignment: Alignment.center,
        width: 37,
        height: 20,
        child: Text('复制', style: TextStyle(color: AppColors.C_222222, fontSize: 11)),
      ),
      onTap: () {
        Clipboard.setData(ClipboardData(text: text)).then((value) {
          HUDUtil.toast('复制成功');
        }).catchError((value) {
          HUDUtil.toast('复制失败');
        });
      },
    );
  }
}
